<template>
    <basic-container>
        <el-tabs v-model="activeName" @tab-click="handleClick">
            <el-tab-pane label="工商银行基础" name="A">
                <div style="width:50%;margin-top: 10px;">
                    <avue-form ref="form" v-model="objA" :option="optionA"  @submit="submitA">
                    </avue-form>
                </div>
            </el-tab-pane>
        </el-tabs>
    </basic-container>
</template>

<script>
   import {
       getGhPay,
       setGhPay
   } from "../../api/base/sysSet/ghPaySet";

   export default {
        data() {
            return {
                activeName: 'A',
                objA:{},
                optionA:{
                    emptyBtn:false,
                    labelWidth:'200',
                    labelPosition:'left',
                    column: [{
                        label: "商户公钥路径",
                        prop: "ghpayMerCrtPath",
                        span: 24,
                        rules: [{
                            required: true,
                            message: "商户公钥路径",
                            trigger: "blur"
                        }]
                    },{
                        label: "商户私钥路径",
                        prop: "ghpayMerKeyPath",
                        span: 24,
                        rules: [{
                            required: true,
                            message: "商户私钥路径",
                            trigger: "blur"
                        }]
                    },{
                        label: "商户证书密码",
                        prop: "ghpayMerKeyPassword",
                        span: 24,
                        rules: [{
                            required: true,
                            message: "商户证书密码",
                            trigger: "blur"
                        }]
                    },{
                        label: "银行公钥路径",
                        prop: "ghpayBankCrtPath",
                        span: 24,
                        rules: [{
                            required: true,
                            message: "银行公钥路径",
                            trigger: "blur"
                        }]
                    },{
                        label: "商户代码",
                        prop: "ghpayMerId",
                        span: 24,
                        display:false,
                        rules: [{
                            required: true,
                            message: "商户代码",
                            trigger: "blur"
                        }]
                    },{
                        label: "商户账号",
                        prop: "ghpayMerAcct",
                        span: 24,
                        display:false,
                        rules: [{
                            required: true,
                            message: "商户账号",
                            trigger: "blur"
                        }]
                    },{
                        label: "通知地址",
                        prop: "ghpayMerUrl",
                        span: 24,
                        rules: [{
                            required: true,
                            message: "请输入通知地址",
                            trigger: "blur"
                        }]
                    },{
                        label: "shopAppId 微信使用",
                        prop: "ghpayShopAppId",
                        span: 24,
                        rules: [{
                            required: true,
                            message: "请输入shopAppId",
                            trigger: "blur"
                        }]
                    },{
                        label: "退款地址",
                        prop: "ghpayRefundUrl",
                        span: 24,
                        rules: [{
                            required: true,
                            message: "请输入退款地址",
                            trigger: "blur"
                        }]
                    },{
                        label: "退款查询地址",
                        prop: "ghpayQueryRefundUrl",
                        span: 24,
                        rules: [{
                            required: true,
                            message: "退款查询地址",
                            trigger: "blur"
                        }]
                    },{
                        label: "支付查询地址",
                        prop: "ghpayQueryUrl",
                        span: 24,
                        rules: [{
                            required: true,
                            message: "请输入支付查询地址",
                            trigger: "blur"
                        }]
                    },{
                        label: "工行分配的AppId",
                        prop: "ghpayAppId",
                        span: 24,
                        rules: [{
                            required: true,
                            message: "请输入工行分配的AppId",
                            trigger: "blur"
                        }]
                    },{
                        label: "商户私钥",
                        prop: "ghpayMY_PRIVATE_KEY",
                        span: 24,
                        rules: [{
                            required: true,
                            message: "请输入商户私钥",
                            trigger: "blur"
                        }]
                    },{
                        label: "网关公钥",
                        prop: "ghpayAPIGW_PUBLIC_KEY",
                        span: 24,
                        rules: [{
                            required: true,
                            message: "请输入网关公钥",
                            trigger: "blur"
                        }]
                    }]
                    }
            }
        },
        //页面初始化
        created(){
           this.getData()
        },
        methods: {
            getData(){
                getGhPay().then(res=>{
                    if(res.data.code==200){
                        let obj=res.data.data
                        console.info(obj);
                        // 基础
                        this.objA.ghpayMerCrtPath=obj.ghpayMerCrtPath
                        this.objA.ghpayMerKeyPath=obj.ghpayMerKeyPath
                        this.objA.ghpayMerKeyPassword=obj.ghpayMerKeyPassword
                        this.objA.ghpayBankCrtPath=obj.ghpayBankCrtPath
                        this.objA.ghpayMerId=obj.ghpayMerId
                        this.objA.ghpayMerAcct=obj.ghpayMerAcct
                        this.objA.ghpayMerUrl=obj.ghpayMerUrl
                        this.objA.ghpayShopAppId=obj.ghpayShopAppId
                        this.objA.ghpayRefundUrl=obj.ghpayRefundUrl
                        this.objA.ghpayQueryRefundUrl=obj.ghpayQueryRefundUrl
                        this.objA.ghpayQueryUrl=obj.ghpayQueryUrl
                        this.objA.ghpayAppId=obj.ghpayAppId
                        this.objA.ghpayMY_PRIVATE_KEY=obj.ghpayMY_PRIVATE_KEY
                        this.objA.ghpayAPIGW_PUBLIC_KEY=obj.ghpayAPIGW_PUBLIC_KEY
                    }
                })

            },
            handleClick(tab, event) {
                console.log(tab, event);
            },
            submitA (form,done) {
                setGhPay(this.objA).then(res=>{
                    done()
                    this.$message({
                        message:'提交成功',
                        type:'success'
                    })
                    this.activeName='A'
                    this.getData()
                })
            }
        }
    };
</script>
<style>
    h5{
        color: darkred;
        font-weight: bold;
    }
    p{
        line-height: 30px;
    }

</style>